from Base.Base import Base
from selenium.webdriver.common.by import By
from Common.Api_client import ApiClient
class Page2_role_assignMenu(Base):
    def __init__(self, driver):
        super().__init__(driver)
        self.client = ApiClient()
    # 定位器
    # 定位元素后的操作方法
    # 菜单管理
    def click_ment(self):
        by,value = self.client.get_locator("menu", "menu_loc")
        self.click((by, value))
    # 菜单管理 添加按钮

    def click_add_menu(self):
        by, value = self.client.get_locator("menu", "menu_add_loc")
        self.click((by, value))
    # 菜单名称

    def send_menu_name(self,menu_name):
        by, value = self.client.get_locator("menu", "menu_name_loc")
        self.send_keys((by, value), menu_name)
    # 菜单编号
    menu_number_loc=(By.NAME,'number')
    def send_menu_number(self,menu_number):
        by, value = self.client.get_locator("menu", "menu_number_loc")
        self.send_keys((by, value), menu_number)
    # 请求url
    def send_url(self,url):
        by, value = self.client.get_locator("menu", "url_loc")
        self.send_keys((by, value), url)
    # navTabId
    def send_navTabId(self,navTabId):
        by, value = self.client.get_locator("menu", "navTabId_loc")
        self.send_keys((by, value), navTabId)


    # 添加菜单的保存按钮
    def click_save_menu(self):
        by, value = self.client.get_locator("menu", "menu_save_loc")
        self.click((by, value))

    # 弹窗确定按钮

    def click_que(self):
        by, value = self.client.get_locator("alert", "que_loc")
        self.click((by, value))

    # 权限管理
    def click_pms(self):
        by, value = self.client.get_locator("pms", "pms_loc")
        self.click((by, value))
    # 添加权限按钮

    def click_pms_add(self):
        by, value = self.client.get_locator("pms", "pms_add_loc")
        self.click((by, value))
    # 权限名称

    def send_pms_name(self,permissionName):
        by, value = self.client.get_locator("pms", "pms_name_loc")
        self.send_keys((by, value), permissionName)
    # 权限标识
    def send_pms_permission(self,permission):
        by, value = self.client.get_locator("pms", "pms_permission_loc")
        self.send_keys((by, value), permission)
    # 权限描述
    def send_pms_remark(self,remark):
        by, value = self.client.get_locator("pms", "pms_remark_loc")
        self.send_keys((by, value), remark)
    # 权限保存按钮
    def click_pms_save(self):
        by, value = self.client.get_locator("pms", "pms_savd_loc")
        self.click((by, value))
    # 角色管理模块

    def click_role(self):
        by, value = self.client.get_locator("role", "role_loc")
        self.click((by, value))
    # 角色添加按钮

    def click_role_add(self):
        by, value = self.client.get_locator("role", "role_add_loc")
        self.click((by, value))
    # 角色名称

    def send_role_name(self,roleName):
        by, value = self.client.get_locator("role", "role_name_loc")
        self.send_keys((by, value), roleName)
    # 角色编码

    def send_role_code(self,roleCode):
        by, value = self.client.get_locator("role", "role_code_loc")
        self.send_keys((by, value), roleCode)
    # 角色描述

    def send_role_remark(self,remark):
        by, value = self.client.get_locator("role", "role_remark_loc")
        self.send_keys((by, value), remark)
    # 角色保存按钮

    def click_role_save(self):
        by, value = self.client.get_locator("role", "role_sava_loc")
        self.click((by, value))
    # 分配菜单
    def click_fen_meun(self):
        by, value = self.client.get_locator("role", "fen_meun_loc")
        self.click((by, value))
    # 勾选分配菜单

    gou_menu_loc=(By.ID,"menuId135")
    def click_gou_menu(self):
        by1, value1 = self.client.get_locator("role", "menu_quan_loc")
        self.click((by1, value1))
        self.click((by1, value1))
        by2, value2 = self.client.get_locator("role", "gou_menu_loc")
        self.click((by2, value2))
    # 分配菜单保存
    def click_fen_save(self):
        by, value = self.client.get_locator("role", "fen_save_loc")
        self.click((by, value))
    # 分配权限

    def click_fen_pms(self):
        by, value = self.client.get_locator("role", "fen_pms_loc")
        self.click((by, value))
    # 勾选权限


    def click_gou_pms(self):
        by1, value1 = self.client.get_locator("role", "pms_quan_loc")
        self.click((by1, value1))
        self.click((by1, value1))
        by2, value2 = self.client.get_locator("role", "gou_pms_loc")
        self.click((by2, value2))
    # 权限分配保存

    def click_fen_pms_save(self):
        by, value = self.client.get_locator("role", "fen_pms_save_loc")
        self.click((by, value))
    # 弹窗返回内容
    def get_tean_text(self):
        by, value = self.client.get_locator("alert", "tan_text_loc")
        print(by, value)
        return self.get_location_text((by, value))